package com.hd.pzhwlxt.controller.model4;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hd.pzhwlxt.pojo.Trans;
import com.hd.pzhwlxt.service.TransService;
import com.hd.pzhwlxt.utils.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @create: 2022-09-26 18:44
 * @author: 怀念天空
 * @Description:
 */
@RestController
public class TransInfoController {

    @Autowired
    private TransService transService;

    /**
     * 处理完的订单在这里显示
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/transInfo")
    public Response<Object> getTransInfo(@RequestParam(value = "pageNum", required = false) Integer pageNum, @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        if (pageNum == null || pageSize == null) {
            List<Trans> result = transService.getTransInfo();
            if (result != null) {
                return Response.createSuccessResponse("查询成功", result);
            }
        } else {
            Page<Trans> result = transService.getTransInfoPage(new Page<>(pageNum, pageSize));
            if (result != null) {
                return Response.createSuccessResponse("查询成功", result);
            }
        }
        return Response.createErrorResponse("查询失败");
    }
}
